package prettyprolog.datatypes;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.ObjectStreamException;

public class Nil extends AbstractTerm {

	private static final long serialVersionUID = 1L;

	public static final Nil NIL = new Nil();

	private Nil() {}
	
	public Term car() {
		return this;
	}
	
	public Term cdr() {
		return this;
	}

	public String toString() {
		return "[]";
	}

	public int hashCode() {
		return System.identityHashCode(this);
	}

	public boolean equals(Object obj) {
		return obj == this;
	}

	private void writeObject(ObjectOutputStream out) throws IOException {
	}

	private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
	}

	private Object readResolve() throws ObjectStreamException {
		return NIL;
	}

	public int length() {
		return 0;
	}

}
